﻿using System;
using System.Collections.Generic;
using System.Text;

namespace TerminationCall.Editor.Logic {
    public class ObjectPainter : IPainter {

        public bool DrawBackground {
            get;
            set;
        }

        public EditorToolManager EditorToolManager {
            set;
            private get;
        }

        public PaintTile[] PaintTiles(System.Drawing.Point location) {

            List<PaintTile> paintTiles = new List<PaintTile>();

            if (EditorToolManager.EditorTool.ChoosenTileObjectGroup == null) {
                return paintTiles.ToArray();
            }

            for (int x = 0; x < EditorToolManager.EditorTool.ChoosenTileObjectGroup.Rectangle.Width; x++) {
                for (int y = 0; y < EditorToolManager.EditorTool.ChoosenTileObjectGroup.Rectangle.Height; y++) {
                    if (DrawBackground) {
                        EditorToolManager.SetSingleTile(location.X + x, location.Y + y, EditorToolManager.EditorTool.ChoosenTileSet.Tiles[EditorToolManager.EditorTool.ChoosenTileObjectGroup.Rectangle.Left + x, EditorToolManager.EditorTool.ChoosenTileObjectGroup.Rectangle.Top + y], TerminationCall.Core.TileFields.BackgroundTile);
                    } else {
                        EditorToolManager.SetSingleTile(location.X + x, location.Y + y, EditorToolManager.EditorTool.ChoosenTileSet.Tiles[EditorToolManager.EditorTool.ChoosenTileObjectGroup.Rectangle.Left + x, EditorToolManager.EditorTool.ChoosenTileObjectGroup.Rectangle.Top + y], TerminationCall.Core.TileFields.ForegroundTile);
                    }
                }
            }
            
            return paintTiles.ToArray();

        }

    }
}
